Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dune: bump to 3.8 #79

Merged
merged 4 commits into from
Nov 30, 2023
Merged

dune: bump to 3.8 #79

merged 4 commits into from
Nov 30, 2023

Conversation

Alizter
Copy link
Contributor

@Alizter Alizter commented May 23, 2023

Dune 3.8 has support for composing with installed Coq theories. So here is an updated dune file. The native rules are also chosen according to how coqc was configured so no need to explicitly enable it.

Copy link
Member

@pi8027 pi8027 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Alizter Thank you for the PR. I recently became the maintainer of multinomials and I'm taking a look at old PRs. Would you mind rebasing and updating (if needed) the PR? I don't know how to write a dune configuration but I can test it.

src/dune Outdated Show resolved Hide resolved
@Alizter
Copy link
Contributor Author

Alizter commented Nov 27, 2023

@pi8027 If you are interested, I can also set it up so that Dune generates the .opam file from package bounds set in dune-project.

@Alizter
Copy link
Contributor Author

Alizter commented Nov 27, 2023

You also probably don't need the configure script any longer.

Signed-off-by: Ali Caglayan <[email protected]>
@pi8027
Copy link
Member

pi8027 commented Nov 27, 2023

@Alizter What is the advantage of that approach compared to coq-community templates? (I didn't even know it was possible to generate .opam file using Dune. As a maintainer, I rather don't want to depend too much on a tool I'm not familiar with.)

@Alizter
Copy link
Contributor Author

Alizter commented Nov 27, 2023

There is currently no strong advantage apart from not having to edit an opam file by hand, which can lead to syntax errors.

In the future, Dune will be able to build package dependencies of projects, allowing for Dune to be the only dependency needed to build this package. That is still some time off, so I'll just drop what the dune-project file will probably look like:

(generate_opam_files true)

(package
 (name coq-mathcomp-multinomials)
 (synopsis
  "A Multivariate polynomial Library for the Mathematical Components Library")
 (depends
  (coq
   (or
    (and
     (>= "8.16")
     (< "8.19~"))
    (= "dev")))
  (coq-mathcomp-ssreflect
   (or
    (and
     (>= "2.0")
     (< "2.2~"))
    (= "dev")))
  coq-mathcomp-algebra
  (coq-mathcomp-bigenough
   (or
    (and
     (>= "1.0")
     (< "1.1~"))
    (= "dev")))
  (coq-mathcomp-finmap
   (or
    (and
     (>= "2.0")
     (< "2.1~"))
    (= "dev"))))
 (maintainers "[email protected]")
 (homepage "https://github.com/math-comp/mulinomials")
 (bug_reports "https://github.com/math-comp/multinomials/issues")
 (license "CECILL-B")
 (authors "Pierre-Yves Strub")
 (tags
  "keyword:multinomials"
  "keyword:monoid algebra"
  "category:Mathematics/Algebra/Multinomials"
  "category:Mathematics/Algebra/Monoid algebra"
  "logpath:mathcomp.multinomials"))

This can be used in the future as a starting point, when Dune might be more useful here. Only the dev-repo field is dropped in the generated file, but that can be added using a template. (Don't worry about it too much).

@Alizter
Copy link
Contributor Author

Alizter commented Nov 27, 2023

I've rebased, two questions:

  1. Do we still need to ignore these warnings?
  2. Shall we get rid of the configure script? Which as I understand tweaks a dune file depending on the native setting. Dune >= 3.8 means this isn't necessary any longer.

@ybertot
Copy link
Member

ybertot commented Nov 27, 2023

Concerning the template you inserted above, it should be used with caution: you miss-spelled the mail address of Pierre-Yves, but moreover, I thought it had been agreed that Pierre-Yves was not maintainer anymore.

@Alizter
Copy link
Contributor Author

Alizter commented Nov 27, 2023

@ybertot That's fine, it can be updated as needed. I just wanted to demonstrate which structural elements would be needed. I've corrected the typo (sorry).

The information is just what I read from the opam file. I'm being agnostic to the actual relevancy of the information contained within.

@Alizter Alizter marked this pull request as draft November 27, 2023 15:24
@Alizter
Copy link
Contributor Author

Alizter commented Nov 27, 2023

I'll try to resolve the build errors locally. It seems something changed since I posted the PR which I will need to understand.

@pi8027
Copy link
Member

pi8027 commented Nov 27, 2023

There is currently no strong advantage apart from not having to edit an opam file by hand, which can lead to syntax errors.

If I generate the .opam file using the coq-community templates, I'm not going to edit the .opam file by hand. (Well, it would be possible to trigger a syntax error by writing broken version constraints, but that unlikely happens.)

  1. Do we still need to ignore these warnings?

They are also suppressed in MathComp. So I think that the answer is yes.

  1. Shall we get rid of the configure script? Which as I understand tweaks a dune file depending on the native setting. Dune >= 3.8 means this isn't necessary any longer.

That would be a question to @erikmd.

@Alizter
Copy link
Contributor Author

Alizter commented Nov 27, 2023

If I generate the .opam file using the coq-community templates, I'm not going to edit the .opam file by hand. (Well, it would be possible to trigger a syntax error by writing broken version constraints, but that unlikely happens.)

That's fine, let's forget about this for now.

@pi8027
Copy link
Member

pi8027 commented Nov 28, 2023

I attempted to fix CI but it did not work. The invocations of coqdep and coqc seem to lack some -R.

@Alizter
Copy link
Contributor Author

Alizter commented Nov 28, 2023

Rather than -R Dune is using -Q, which I think is fine. In my unfinished attempt, I added the elpi library and plugin to the plugins field, but Coq cannot load the plugin. Curiously, removing the -boot flag (which is always passed in Dune as to have explicit dependencies), allows the plugin to be loaded. So it seems we have run into a Coq issue that I am not quite sure how to resolve. cc @ejgallego

Here is what I am using:

(coq.theory
 (name mathcomp.multinomials)
 (package coq-mathcomp-multinomials)
 (flags
  -w -ambiguous-paths
  -w -notation-overridden
  -w -redundant-canonical-projection
  -w -projection-no-head-constant)
 (plugins coq-elpi.elpi elpi)
 (theories
  HB
  elpi
  mathcomp.ssreflect
  mathcomp.algebra
  mathcomp.bigenough
  mathcomp.finmap))

The command Dune is attempting to run is:

$ (cd _build/default && /home/ali/repos/multinomials/_opam/bin/coqc -w -ambiguous-paths -w -notation-overridden -w -redundant-canonical-projection -w -projection-no-head-constant -w -deprecated-native-compiler-option -w -native-compiler-disabled -native-compiler ondemand -boot -I /home/ali/repos/multinomials/_opam/lib/coq-core/boot -I /home/ali/repos/multinomials/_opam/lib/coq-core/clib -I /home/ali/repos/multinomials/_opam/lib/coq-core/config -I /home/ali/repos/multinomials/_opam/lib/coq-core/engine -I /home/ali/repos/multinomials/_opam/lib/coq-core/gramlib -I /home/ali/repos/multinomials/_opam/lib/coq-core/interp -I /home/ali/repos/multinomials/_opam/lib/coq-core/kernel -I /home/ali/repos/multinomials/_opam/lib/coq-core/lib -I /home/ali/repos/multinomials/_opam/lib/coq-core/library -I /home/ali/repos/multinomials/_opam/lib/coq-core/parsing -I /home/ali/repos/multinomials/_opam/lib/coq-core/plugins/ltac -I /home/ali/repos/multinomials/_opam/lib/coq-core/pretyping -I /home/ali/repos/multinomials/_opam/lib/coq-core/printing -I /home/ali/repos/multinomials/_opam/lib/coq-core/proofs -I /home/ali/repos/multinomials/_opam/lib/coq-core/tactics -I /home/ali/repos/multinomials/_opam/lib/coq-core/vernac -I /home/ali/repos/multinomials/_opam/lib/coq-core/vm -I /home/ali/repos/multinomials/_opam/lib/coq-elpi -I /home/ali/repos/multinomials/_opam/lib/elpi -I /home/ali/repos/multinomials/_opam/lib/elpi/lexer_config -I /home/ali/repos/multinomials/_opam/lib/elpi/parser -I /home/ali/repos/multinomials/_opam/lib/elpi/trace/runtime -I /home/ali/repos/multinomials/_opam/lib/elpi/util -I /home/ali/repos/multinomials/_opam/lib/findlib -I /home/ali/repos/multinomials/_opam/lib/menhirLib -I /home/ali/repos/multinomials/_opam/lib/ppx_deriving/runtime -I /home/ali/repos/multinomials/_opam/lib/re -I /home/ali/repos/multinomials/_opam/lib/re/str -I /home/ali/repos/multinomials/_opam/lib/result -I /home/ali/repos/multinomials/_opam/lib/seq -I /home/ali/repos/multinomials/_opam/lib/stdlib-shims -I /home/ali/repos/multinomials/_opam/lib/zarith -I /nix/store/bink43irwl4lp7fli0lh6j82zsrkycp5-ocaml-4.14.1/lib/ocaml -I /nix/store/bink43irwl4lp7fli0lh6j82zsrkycp5-ocaml-4.14.1/lib/ocaml/threads -I /home/ali/repos/multinomials/_opam/lib/coq/../coq-core/plugins/btauto -I /home/ali/repos/multinomials/_opam/lib/coq/../coq-core/plugins/cc -I /home/ali/repos/multinomials/_opam/lib/coq/../coq-core/plugins/derive -I /home/ali/repos/multinomials/_opam/lib/coq/../coq-core/plugins/extraction -I /home/ali/repos/multinomials/_opam/lib/coq/../coq-core/plugins/firstorder -I /home/ali/repos/multinomials/_opam/lib/coq/../coq-core/plugins/funind -I /home/ali/repos/multinomials/_opam/lib/coq/../coq-core/plugins/ltac -I /home/ali/repos/multinomials/_opam/lib/coq/../coq-core/plugins/ltac2 -I /home/ali/repos/multinomials/_opam/lib/coq/../coq-core/plugins/micromega -I /home/ali/repos/multinomials/_opam/lib/coq/../coq-core/plugins/nsatz -I /home/ali/repos/multinomials/_opam/lib/coq/../coq-core/plugins/number_string_notation -I /home/ali/repos/multinomials/_opam/lib/coq/../coq-core/plugins/ring -I /home/ali/repos/multinomials/_opam/lib/coq/../coq-core/plugins/rtauto -I /home/ali/repos/multinomials/_opam/lib/coq/../coq-core/plugins/ssreflect -I /home/ali/repos/multinomials/_opam/lib/coq/../coq-core/plugins/ssrmatching -I /home/ali/repos/multinomials/_opam/lib/coq/../coq-core/plugins/tauto -I /home/ali/repos/multinomials/_opam/lib/coq/../coq-core/plugins/tutorial/p0 -I /home/ali/repos/multinomials/_opam/lib/coq/../coq-core/plugins/tutorial/p1 -I /home/ali/repos/multinomials/_opam/lib/coq/../coq-core/plugins/tutorial/p2 -I /home/ali/repos/multinomials/_opam/lib/coq/../coq-core/plugins/tutorial/p3 -I /home/ali/repos/multinomials/_opam/lib/coq/../coq-core/plugins/zify -I /home/ali/repos/multinomials/_opam/lib/coq/user-contrib/elpi -I /home/ali/repos/multinomials/_opam/lib/coq/user-contrib/elpi/apps -R /home/ali/repos/multinomials/_opam/lib/coq/theories Coq -Q /home/ali/repos/multinomials/_opam/lib/coq/user-contrib/HB HB -Q /home/ali/repos/multinomials/_opam/lib/coq/user-contrib/elpi elpi -Q /home/ali/repos/multinomials/_opam/lib/coq/user-contrib/mathcomp/ssreflect mathcomp.ssreflect -Q /home/ali/repos/multinomials/_opam/lib/coq/user-contrib/mathcomp/algebra mathcomp.algebra -Q /home/ali/repos/multinomials/_opam/lib/coq/user-contrib/mathcomp/bigenough mathcomp.bigenough -Q /home/ali/repos/multinomials/_opam/lib/coq/user-contrib/mathcomp/finmap mathcomp.finmap -R src mathcomp.multinomials src/freeg.v)

giving me the following error:

 File "./src/freeg.v", line 26, characters 0-34:
> Error:
> Findlib error: coq-elpi.elpi not found in:
> /home/ali/repos/multinomials/_opam/lib/coq-core/boot
> /home/ali/repos/multinomials/_opam/lib/coq-core/clib
> /home/ali/repos/multinomials/_opam/lib/coq-core/config
> /home/ali/repos/multinomials/_opam/lib/coq-core/engine
> /home/ali/repos/multinomials/_opam/lib/coq-core/gramlib
> /home/ali/repos/multinomials/_opam/lib/coq-core/interp
> /home/ali/repos/multinomials/_opam/lib/coq-core/kernel
> /home/ali/repos/multinomials/_opam/lib/coq-core/lib
> /home/ali/repos/multinomials/_opam/lib/coq-core/library
> /home/ali/repos/multinomials/_opam/lib/coq-core/parsing
> /home/ali/repos/multinomials/_opam/lib/coq-core/plugins/ltac
> /home/ali/repos/multinomials/_opam/lib/coq-core/pretyping
> /home/ali/repos/multinomials/_opam/lib/coq-core/printing
> /home/ali/repos/multinomials/_opam/lib/coq-core/proofs
>

I can reproduce when running that command (which I took from _build/log). When I remove -boot, Coq compiles. So something is interacting weirdly with findlib plugin loading in Coq and the -boot flag.

@ejgallego
Copy link

ejgallego commented Nov 28, 2023

I think @Alizter 's problem is due to Coq / CoqDune not supporting his hybrid setup where ocamlfind doesn't come from OPAM (but the rest of OCaml deps do)

For the CI here, I think what is happening is simpler, are you sure the new dune file is not overwritten by the Makefile logic that uses dune.in ?

Certainly it seems like the output corresponds to the old dune file.

@pi8027
Copy link
Member

pi8027 commented Nov 28, 2023

@ejgallego Thanks. I fixed the CI issue.

@Alizter Do we agree to merge this as is and open another PR to see if we can remove the configure script?

src/dune.in Outdated Show resolved Hide resolved
@Alizter
Copy link
Contributor Author

Alizter commented Nov 28, 2023

@pi8027 I'm happy with it if you are. Let's make sure the CI is happy too.

@Alizter Alizter marked this pull request as ready for review November 28, 2023 16:27
@pi8027
Copy link
Member

pi8027 commented Nov 28, 2023

BTW, we probably need to fix the version constraint on dune in the opam file.

@Alizter
Copy link
Contributor Author

Alizter commented Nov 28, 2023

Yes @pi8027, another thing that we wouldn't need to worry about if we generated. Adding >= 3.8 should be sufficient.

@pi8027
Copy link
Member

pi8027 commented Nov 28, 2023

To be clear, I won't use Dune to generate stuff unless I see a significant advantage over the coq-community templates. Most MathComp-related packages use the coq-community templates for that purpose. So, the coq-community templates have an advantage over Dune that it is easier for us to maintain.

In general, I would only accept patches I (or other MathComp devs) can maintain. That also applies to the removal of the configure script.

@Alizter
Copy link
Contributor Author

Alizter commented Nov 28, 2023

@pi8027 That's fine, I was only mentioning that in passing.

The configure script, AFAIU is a way to get around an issue with older versions of Dune where you would have to state the native rules explicitly. Now this is done automatically by Dune, therefore it might be time to remove it. (Doesn't have to be this PR I suppose).

cc @proux01 who I believe I discussed this issue with a few years ago.

@proux01
Copy link
Contributor

proux01 commented Nov 28, 2023

I can confirm that the configure script was only a hack to workaround the deficiencies of dune < 3.8, so requiring dune >= 3.8 means removing the configure script (and moving src/dune.in to src/dune).

To be clear I'am in favor of either moving to dune >= 3.8 or moving back to coq_makefile, either solution would be an improvement over the current hackish status.

@proux01
Copy link
Contributor

proux01 commented Nov 28, 2023

(but in case of moving back to coq_makefile, please notify me because I would need to update the Nix package or CI would be broken)

@pi8027
Copy link
Member

pi8027 commented Nov 29, 2023

I also don't know the reason behind the use of Dune, and I won't go back to coq_makefile without knowing the reason. (Such a change can complicate the reviewing and merging process, and I suggest not doing that in this PR.) 3485ea6

@proux01
Copy link
Contributor

proux01 commented Nov 29, 2023

I guess only @strub might remember the reason for the use of Dune here.

Copy link
Member

@pi8027 pi8027 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please choose whether

  1. to not remove the configure script, not remove the comment line in dune.in, and not move dune.in to dune, or
  2. to remove the configure script, remove the comment line in dune.in, and move dune.in to dune.

(The last commit f22432e does the second item but does not do the rest. Therefore, I'm not accepting the patch.)

In the latter case, approval from someone who worked on this configure script (Érik or Pierre ?) is required.

@proux01
Copy link
Contributor

proux01 commented Nov 29, 2023

I vote for 2 (and thereby approve it).

@pi8027
Copy link
Member

pi8027 commented Nov 29, 2023

@Alizter I think you need to remove /src/dune from .gitignore again, readd /src/dune.in as /src/dune, and remove the invocation of the configure script from the opam file.

@Alizter
Copy link
Contributor Author

Alizter commented Nov 29, 2023

@pi8027 Yes sorry, I pushed then realised, but I was in the middle of setting up my opam switch again. I will push a tested fix shortly.

Signed-off-by: Ali Caglayan <[email protected]>
@Alizter
Copy link
Contributor Author

Alizter commented Nov 29, 2023

@pi8027 This should be ready now. Hopefully the CI agrees.

@Alizter Alizter requested a review from pi8027 November 29, 2023 17:19
Copy link
Member

@pi8027 pi8027 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me. I will merge if CI does not complain. Thanks!

pi8027 added a commit to pi8027/opam-coq-archive that referenced this pull request Nov 30, 2023
@pi8027 pi8027 merged commit 4c8c7e9 into math-comp:master Nov 30, 2023
10 checks passed
@proux01
Copy link
Contributor

proux01 commented Nov 30, 2023

Thanks a lot @Alizter for finally fixing this !

@Alizter Alizter deleted the dune-3-8 branch November 30, 2023 16:23
pi8027 added a commit to pi8027/opam-coq-archive that referenced this pull request Nov 30, 2023
proux01 added a commit to proux01/math-comp that referenced this pull request Dec 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants